class PublishService {

    boolean transactional = true

    def createPost(options) {
        def privce = false
        def classerID = 0
        def site
        
        def author = Author.findByHostId(options.authorID.toLong()) //老师
        def student
        if(options.studentId){
            student = Student.findByHostId(options.studentId.toLong()) // 学生的站点
        }
        def classer
        if(options.classesHostId){
            classer = Classer.findByHostId(options.classesHostId?.toLong())
        }
        //def classer = Classer.findByHostId(options.classesHostId?.toLong())
        if(student){
            site = student.site
        }else{
            site = classer.site
        }
        
        if(classer){
            classerID = classer.hostId
        }else{
            privce = true
        }
        Post post = new Post(
                        title: options.title,
                        content: options.content,
                        displayDate: new Date(),
                        author:author,
                        privce:privce,
                        school:options.schoolId,
                        classesid:classerID,
                        site:site)
        // author.site = Author.findByHostId(options.siteId) 
        author.addToPosts(post)
        author.save()       
    }
}
